# Huawei Technologies Co.,Ltd.

set(MISSINGARGS_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/missingargs.txt)
set(MISSINGARGS_BIN ${CMAKE_CURRENT_BINARY_DIR}/missingargs.abc)
set(MISSINGARGS_JS ${CMAKE_CURRENT_SOURCE_DIR}/missingargs.js)
set(MISSINGARGS_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${PANDA_BINARY_ROOT}/pandastdlib/arkstdlib.abc --load-runtimes=\"ecmascript\" --compiler-enable-jit=false --gc-type=epsilon ${MISSINGARGS_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${MISSINGARGS_OUTPUT}
    COMMENT "running javascript missingargs testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${MISSINGARGS_JS} --output ${MISSINGARGS_BIN}
    COMMAND rm -f ${MISSINGARGS_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} 2>&1 > ${MISSINGARGS_OUTPUT}
    COMMAND bash ${MISSINGARGS_VERIFY} ${MISSINGARGS_OUTPUT}
)
add_custom_target(missingargs
    DEPENDS ${MISSINGARGS_OUTPUT} ${MISSINGARGS_VERIFY}
)
add_dependencies(missingargs es2panda ark)
if(PANDA_TARGET_64)
    add_dependencies(ecmascript_tests missingargs)
endif()
